let Sequelize = require("sequelize")
//加载 sequelize-auto 自动生成的init-models文件
let initModels = require("../models/init-models")
let sequelize = new Sequelize('tpadmin','root','716ac8485e',{
    host:'localhost',
    port:3306,
    dialect:"mysql",
    pool:{
        max:5,
        min:0,
        idle:10000,
    },
    logging:false,
})

sequelize.authenticate().then(()=>{
    console.log('数据库连接成功');
}).catch((err)=>{
    console.log('数据库连接失败');
})
// 放进 initModels方法使用
const models = initModels(sequelize)
// 导出
module.exports = {...models,sequelize}

